#import "DDZFInfoCell.h"
CGFloat const JTWZFINFOCELLHEIGHT = 44;
@interface DDZFInfoCell()
@property (nonatomic, strong) CCLabel *titleLBL;
@property (nonatomic, strong) CCLabel *contentLBL;
@property (nonatomic, strong) DDButton *btn;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UIView *rightLine;
@end
@implementation DDZFInfoCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        _para.index = 10000;
        self.backgroundColor = [UIColor whiteColor];
        [CCNotice addObs:self sel:@selector(yjd_cellRotate) name:UIApplicationDidChangeStatusBarOrientationNotification obj:nil];    }
    return self;
}
- (CCLabel *)titleLBL
{
    if (!_titleLBL)
    {
        _titleLBL = [[CCLabel alloc] init];
        _titleLBL.font = FONT(UIFontWeightRegular, 15);
        _titleLBL.textColor = TEXT_GRAY_COLOR;
        [self addSubview:_titleLBL];
        _titleLBL.c_left.equal(self).with.coffset(GAP);
        _titleLBL.c_centerY.equal(self);
    }
    return _titleLBL;
}
- (CCLabel *)contentLBL
{
    if (!_contentLBL)
    {
        _contentLBL = [[CCLabel alloc] init];
        _contentLBL.font = FONT(UIFontWeightRegular, 15);
        _contentLBL.textColor = TEXT_GRAY_COLOR;
        [self addSubview:_contentLBL];
        _contentLBL.c_right.equal(self).with.coffset(-GAP);
        _contentLBL.c_centerY.equal(self);
    }
    return _contentLBL;
}
- (DDButton *)btn
{
    if (!_btn)
    {
        _btn = [[DDButton alloc] init];
        _btn.font = FONT(UIFontWeightRegular, 15);
        _btn.autoTitleSize = YES;
        [_btn setValue:helpermanger().getPara().color forKeyPath:@"_label.textColor"];
        [_btn addTarget:self action:@selector(yjd_actionForWuquan) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_btn];
        _btn.c_right.equal(self).with.coffset(-GAP);
        _btn.c_centerY.equal(self);
    }
    return _btn;
}
- (UIView *)line
{
    if (!_line)
    {
        _line = [[UIView alloc] init];
        _line.backgroundColor = CELL_LINE_COLOR;
        [self addSubview:_line];
        _line.c_left.equal(self).with.coffset(0);
        _line.c_right.equal(self).with.coffset(0);
        _line.c_bottom.equal(self);
        _line.c_height.equal(1.0);
    }
    return _line;
}
- (UIView *)rightLine
{
    if (!_rightLine)
    {
        _rightLine = [[UIView alloc] init];
        _rightLine.backgroundColor = CELL_LINE_COLOR;
        [self addSubview:_rightLine];
        _rightLine.c_right.equal(self);
        _rightLine.c_bottom.equal(self);
        _rightLine.c_top.equal(self);
        _rightLine.c_width.equal(1.0);
    }
    return _rightLine;
}
DDZFInfoCellManager zfInfoCellManager()
{
    DDZFInfoCellManager manager =
    {
        _getPara,
        _setPara
    };
    return manager;
};
static DDZFInfoCellPara _para;
static DDZFInfoCellPara _getPara()
{
    return _para;
}
static void _setPara(DDZFInfoCell *cell, DDZFInfoCellPara para)
{
    _para = para;
    cell.titleLBL.text = _para.title;
    if (_para.index == 5)
    {
        cell.btn.title = _para.content;
        [cell->_contentLBL removeFromSuperview];
        cell->_contentLBL = nil;
    }
    else
    {
        cell.contentLBL.text = _para.content;
        [cell->_btn removeFromSuperview];
        cell->_btn = nil;
    }
    [cell yjd_cellRotate];
    
}
- (void)yjd_actionForWuquan
{
    if (_para.block)
    {
        _para.block();
    }
}
- (void)yjd_cellRotate
{
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        self.line.hidden = (_para.index < 5)?NO:YES;
        self.rightLine.hidden = (_para.index % 2)?YES:NO;
    }
    else
    {
        self.line.hidden = (_para.index < 6)?NO:YES;
        self.rightLine.hidden = YES;
    }
}
- (void)dealloc
{
    [CCNotice rmObs:self name:UIApplicationDidChangeStatusBarOrientationNotification obj:nil];
}

@end
